
class UserWXPCase {
    constructor() {
        //this.token = null;
        this.token = "cc55f586c23f656ce4bea7f9faa3348e"; //user-test1 13764474169
        //this.token = "0a72e967c978c05d1d4191d313adebd0"; //user-test2
    }

    getClient() {
        return new MyHttpClient("localhost", 10002, "", "baoflyflyertkn");
        //return new MyHttpClient("flyer.feishou.com", 80, "", "baoflyflyertkn");
    }

    lgwx() {
        if(this.token != null) {
            return true;
        }
        //weixinInfo 微信昵称头像等信息，json字符串
        let obj = {"weixinCode": "061tOcll2AWeD74O7oll2tX80z2tOclx", "weixinInfo":"{\"nickName\":\"parent2\",\"gender\":1,\"language\":\"zh_CN\",\"city\":\"松江\",\"province\":\"Shanghai\",\"country\":\"China\",\"avatarUrl\":\"https://thirdwx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEJguxLTiaLEKnD9FXTtlkUdjVOUUVlyqbwzdXL34PVeZDBY4n18z3SnicoibFOOOfyQHzxcThhwd3VhA/132\"}"};
        this.getClient().postJson("/lgwx", JSON.stringify(obj), (data) => {
            this.token = data.data.token;
            //{"code":0,"msg":"login successful","clsName":"UserLoginRes","data":{"token":"4b99cb0eb612e39fa4f4af27cea8f46d","realUserId":null,"auditStatus":0}}
            //-1, "wxnet error"
            //-2, "parse error"
            //-3, "code error"
            //-4, "weixin limit"
            //-5, "weixinid, unionid: none"
            //-6, "system error"
            //-7, "account none"
            //-8, "account disable"
            console.info('lgwx');
            return true;
        }, (err) => {
            console.error('lgwx, ' + err);
            return false;
        }, null);
    }
    //登出
    logout() {
        this.getClient().getJson("/logout", (data) => {
            console.info('logout, ');
            //{"code":0,"msg":null,"clsName":null,"data":null}
            return true;
        }, (err) => {
            console.error('logout, ' + err);
            return false;
        }, this.token);
    }
    //绑定手机
    bindMobile() {
        if(this.token == null) {
            return;
        }
        let obj = {"encryptedData": "OkQySaxxYhum7REYI4frScaygjuetYww3r8pyRPmWPQ6f7JtBjyjBIM/PhECHEkOC8TMLVLVn3mFYPvD250Z6Zwzu3QdCrgbowkAzVZVg8koF1UqQQUj8MhA02N/7AS5vQbnzSMMS6WocRU92NETJc+6tQzRdCQ8vDLS35M2v7ineHHEpi4/wFwZ2qej3eewcIAoCXx1w4K2LbWk7e8+RA==",
            "iv":"hn9XpCFcVOPtFmUADdBprA=="};
        this.getClient().postJson("/user/bindMobile", JSON.stringify(obj), (data) => {
            console.info('bindMobile, ');
            //{"code":0,"msg":null,"clsName":"UserInfoRes","data":{"userId":1,"openId":null,"mobile":"13764474169","realName":null,"districtId":null,"isDisable":0,"createTime":null,"updateTime":null}}
            //-1 "已经绑定手机"
            //-2, "解密手机号错误"
            //-3, "系统错误，不存在"
            //-4, "手机号不一致"
            //-5, "手机号已经被其它微信绑定"
            return true;
        }, (err) => {
            console.error('bindMobile, ' + err);
            return false;
        }, this.token);
    }
    //我的信息
    myInfo() {
        if(this.token == null) {
            return;
        }
        this.getClient().getJson("/user/myInfo", (data) => {
            console.info('myInfo, ');
            //{"code":0,"msg":null,"clsName":"UserInfoRes","data":{"userId":1,"openId":"user-test1","mobile":"13764474169","realName":"郭永超","districtId":110000,"idNo":"4128911","idImgs":"id2.png","nationality":"汉族","headImg":"phtoto.png","gender":1,"birthday":896630400,"homeAddr":"武汉市长江南路2200号","email":"gyc@qq.com","noCriminal":"nocrm.png","isDisable":0,"createTime":1740709270,"updateTime":1740722354}}
            return true;
        }, (err) => {
            console.error('myInfo, ' + err);
            return false;
        }, this.token);
    }
    //修改我的资料
    updInfo() {
        if(this.token == null) {
            return;
        }
        //gender 1-男；2-女；
        let obj = {"realName": "郭永超", "districtId":110000,
            "idNo": "4128911", "idImgs": "id2.png", "nationality": "汉族", "headImg": "phtoto.png",
            "gender": 1, "birthday": new Date("1998-06-01 00:00:00"), "homeAddr": "武汉市长江南路2200号",
            "email": "gyc@qq.com", "noCriminal": "nocrm.png"};
        this.getClient().postJson("/user/updInfo", JSON.stringify(obj), (data) => {
            console.info('updInfo, ');
            //{"code":0,"msg":"操作成功","clsName":null,"data":null}
            //-1, "不存在"
            return true;
        }, (err) => {
            console.error('updInfo, ' + err);
            return false;
        }, this.token);
    }

    //培训机构-列表
    organInfoLst() {
        if(this.token == null) {
            return;
        }
        //organId
        //companyName
        //districtId
        //isDisable
        //curPage 页号，从1开始
        let obj = {"curPage":1, "pageSize":20};
        this.getClient().postJson("/organ/info/list", JSON.stringify(obj), (data) => {
            console.info('organInfoLst, ');
            //{"code":0,"msg":null,"clsName":"DataPageRes<OrganInfoRes>","data":{"recordCount":1,"curPage":1,"pageSize":20,"pageNum":1,"itemLst":[{"organId":1,"companyName":"光谷飞讯","companyAddr":"鸭脖路1001号","districtId":110101,"linkMan":"武汉1","linkMobile":"13769538566","organPin":"f244fe0ba230fab7132eaec0ceeb75c6","isDisable":0,"createTime":1740559766,"updateTime":1740559893,"districtAncestors":null}],"now":null}}
            //-99, "参数错误"
            return true;
        }, (err) => {
            console.error('organInfoLst, ' + err);
            return false;
        }, this.token);
    }
    //培训机构-详情
    organInfoDetail() {
        if(this.token == null) {
            return;
        }
        this.getClient().getJson("/organ/info/detail?organId=1", (data) => {
            console.info('organInfoDetail, ');
            //{"code":0,"msg":null,"clsName":"OrganInfoRes","data":{"organId":1,"companyName":"光谷飞讯","companyAddr":"鸭脖路1001号","districtId":110101,"linkMan":"武汉1","linkMobile":"13769538566","organPin":"f244fe0ba230fab7132eaec0ceeb75c6","isDisable":0,"createTime":1740559766,"updateTime":1740559893,"districtAncestors":null}}
            //-1, "不存在"
            return true;
        }, (err) => {
            console.error('organInfoDetail, ' + err);
            return false;
        }, this.token);
    }

    //培训课程-列表
    organCourseLst() {
        if(this.token == null) {
            return;
        }
        //courseId
        //organId
        //courseName
        //companyName
        //districtId
        //isDisable
        //curPage 页号，从1开始
        let obj = {"curPage":1, "pageSize":20};
        this.getClient().postJson("/organ/course/list", JSON.stringify(obj), (data) => {
            console.info('organCourseLst, ');
            //{"code":0,"msg":null,"clsName":"DataPageRes<OrganCourseRes>","data":{"recordCount":1,"curPage":1,"pageSize":20,"pageNum":1,"itemLst":[{"courseId":1,"organId":1,"courseName":"无人运货","courseFee":50000,"createTime":1740637160,"updateTime":1740637279,"companyName":"光谷飞讯","districtId":110101,"rebateRatio":10,"districtAncestors":null}],"now":null}}
            //-99, "参数错误"
            return true;
        }, (err) => {
            console.error('organCourseLst, ' + err);
            return false;
        }, this.token);
    }
    //培训课程-详情
    organCourseDetail() {
        if(this.token == null) {
            return;
        }
        this.getClient().getJson("/organ/course/detail?courseId=1", (data) => {
            console.info('organCourseDetail, ');
            //{"code":0,"msg":null,"clsName":"OrganCourseRes","data":{"courseId":1,"organId":1,"courseName":"无人运货","courseFee":50000,"createTime":1740637160,"updateTime":1740637279,"companyName":"光谷飞讯","districtId":110101,"rebateRatio":10,"districtAncestors":null}}
            //-1, "不存在"
            return true;
        }, (err) => {
            console.error('organCourseDetail, ' + err);
            return false;
        }, this.token);
    }

    //文章-列表
    articleList() {
        //curPage 页号，从1开始
        let obj = {"curPage":1, "pageSize":20};
        this.getClient().postJson("/cms/articles", JSON.stringify(obj), (data) => {
            console.info('articleList, ');
            //{"code":0,"msg":null,"clsName":"DataPageRes<ArticleInfoRes>","data":{"recordCount":1,"curPage":1,"pageSize":20,"pageNum":1,"itemLst":[{"articleId":2,"title":"专场活动成功举办","mainImg":"https://p7.itc.cn/q_70/images01/20210808/2477a79a0cfc42f698da8d89b3420e3b.jpeg","detail":null,"showTime":null,"targetUrl":null,"orderNo":null,"siteType":null,"catType":null,"onlineStatus":1,"omsUserId":1,"createTime":1740641392,"updateTime":1740641415}],"now":null}}
            //-99, "参数错误"
            return true;
        }, (err) => {
            console.error('articleList, ' + err);
            return false;
        }, this.token);
    }
    //文章-详情
    articleDetail() {
        if(this.token == null) {
            return;
        }
        this.getClient().getJson("/cms/articleDetail?articleId=2", (data) => {
            console.info('articleDetail, ');
            //{"code":0,"msg":null,"clsName":"ArticleInfoRes","data":{"articleId":2,"title":"专场活动成功举办","mainImg":"https://p7.itc.cn/q_70/images01/20210808/2477a79a0cfc42f698da8d89b3420e3b.jpeg","detail":"当苏炳添跑进9秒83，成为人类百米历史上第12快的人、第一个站上决赛跑道的亚洲人，所有人都看到了，这位即将年满32岁的老将代表了一种真正的奥林匹克精神。","showTime":null,"targetUrl":null,"orderNo":null,"siteType":null,"catType":null,"onlineStatus":1,"omsUserId":1,"createTime":1740641392,"updateTime":1740641415}}
            //-1, "不存在"
            return true;
        }, (err) => {
            console.error('articleDetail, ' + err);
            return false;
        }, this.token);
    }

    //订单-列表
    orderInfoList() {
        if(this.token == null) {
            return;
        }
        //orderId
        //orderStatus 订单状态。0-待付款；4-已完成；
        //beginTime     new Date("2022-11-01 00:00:00")
        //endTime       new Date("2022-11-03 23:59:00")
        //curPage 页号，从1开始
        let obj = {"curPage":1, "pageSize":20};
        this.getClient().postJson("/order/info/list", JSON.stringify(obj), (data) => {
            console.info('orderInfoList, ');
            //{"code":0,"msg":null,"clsName":"DataPageRes<OrderInfoRes>","data":{"recordCount":1,"curPage":1,"pageSize":20,"pageNum":1,"itemLst":[{"orderId":2,"userId":1,"skuId":1,"organId":1,"goodsFee":50000,"deductFee":0,"payableFee":50000,"paymentType":0,"paymentStatus":1,"paymentTime":1740839459,"orderStatus":4,"hasRefund":0,"refundFee":0,"createTime":1740839189,"userName":"郭永超","refundLst":null}],"now":null}}
            //-99, "参数错误"
            return true;
        }, (err) => {
            console.error('orderInfoList, ' + err);
            return false;
        }, this.token);
    }
    //订单-详情
    orderInfoDetail() {
        if(this.token == null) {
            return;
        }
        this.getClient().getJson("/order/info/detail?orderId=2", (data) => {
            console.info('orderInfoDetail, ');
            //{"code":0,"msg":null,"clsName":"OrderInfoRes","data":{"orderId":2,"userId":1,"skuId":1,"organId":1,"goodsFee":50000,"deductFee":0,"payableFee":50000,"paymentType":0,"paymentStatus":1,"paymentTime":1740839459,"orderStatus":4,"hasRefund":1,"refundFee":50000,"createTime":1740839189,"userName":"郭永超","refundLst":[{"refundId":2,"reasonType":0,"refundFee":50000,"refundStatus":5,"hasError":0,"auditRemark":"质量没问题，客户自己弄坏的","createTime":1740840278},{"refundId":3,"reasonType":0,"refundFee":50000,"refundStatus":4,"hasError":0,"auditRemark":"麻烦了","createTime":1740840445}]}}
            //-1, "订单不存在"
            return true;
        }, (err) => {
            console.error('orderInfoDetail, ' + err);
            return false;
        }, this.token);
    }
    //订单-下单
    orderInfoAdd() {
        if(this.token == null) {
            return;
        }
        //skuId 课程id
        let obj = {"skuId":1};
        this.getClient().postJson("/order/info/add", JSON.stringify(obj), (data) => {
            console.info('add, ');
            //{"code":0,"msg":null,"clsName":"Long","data":"1"}
            return true;
        }, (err) => {
            console.error('orderInfoAddEntity, ' + err);
            return false;
        }, this.token);
    }
    //订单-取消
    orderInfoClose() {
        if(this.token == null) {
            return;
        }
        let obj = {"orderId":1};
        this.getClient().postJson("/order/info/close", JSON.stringify(obj), (data) => {
            console.info('orderInfoClose, ');
            //{"code":0,"msg":null,"clsName":null,"data":null}
            //-1, "订单不存在"
            //-2, "订单状态错误"
            return true;
        }, (err) => {
            console.error('orderInfoClose, ' + err);
            return false;
        }, this.token);
    }
    //订单-微信预付款
    orderPayWXPay() {
        if(this.token == null) {
            return;
        }
        let obj = {"orderId":2};
        this.getClient().postJson("/order/pay/wxpay", JSON.stringify(obj), (data) => {
            console.info('orderPayWXPay, ');
            //{"code":0,"msg":"成功","clsName":"WebWXPayRes","data":{"appId":"wx408fb15c40013f6d","partnerId":null,"timeStamp":"1666601804","nonceStr":"6b06e71b477544c1ab4ce940be695e35","pkInfo":"prepay_id=wx18160839326373d2e2c54846b781f20000","signType":"MD5","paySign":"932AE3D8D39221497B8FEC908B0F131E","prepayId":null}}
            //-1, "订单不存在"
            //-2, "订单状态错误"
            return true;
        }, (err) => {
            console.error('orderPayWXPay, ' + err);
            return false;
        }, this.token);
    }

    //证书-列表
    certificateInfoList() {
        if(this.token == null) {
            return;
        }
        //userId
        //organId
        //auditStatus 审核状态。0-待审核；1-已通过；2-已驳回；
        //curPage 页号，从1开始
        let obj = {"curPage":1, "pageSize":20};
        this.getClient().postJson("/certificate/info/list", JSON.stringify(obj), (data) => {
            console.info('certificateInfoList, ');
            //{"code":0,"msg":null,"clsName":"DataPageRes<UserCertificateRes>","data":{"recordCount":1,"curPage":1,"pageSize":20,"pageNum":1,"itemLst":[{"certificateId":1,"userId":1,"orderId":2,"refundId":null,"courseId":1,"organId":1,"rebateFee":7500,"certificateUrl":"zf.png","auditStatus":0,"auditRemark":null,"createTime":1740903200,"updateTime":1740903200,"userName":"郭永超"}],"now":null}}
            //-99, "参数错误"
            return true;
        }, (err) => {
            console.error('certificateInfoList, ' + err);
            return false;
        }, this.token);
    }
    //证书-详情
    certificateInfoDetail() {
        if(this.token == null) {
            return;
        }
        this.getClient().getJson("/certificate/info/detail?certificateId=1", (data) => {
            console.info('certificateInfoDetail, ');
            //{"code":0,"msg":null,"clsName":"UserCertificateRes","data":{"certificateId":1,"userId":1,"orderId":2,"refundId":null,"courseId":1,"organId":1,"rebateFee":7500,"certificateUrl":"zf.png","auditStatus":0,"auditRemark":null,"createTime":1740903200,"updateTime":1740903200,"userName":"郭永超"}}
            //-1, "不存在"
            return true;
        }, (err) => {
            console.error('certificateInfoDetail, ' + err);
            return false;
        }, this.token);
    }
    //证书-添加
    certificateInfoAdd() {
        if(this.token == null) {
            return;
        }
        //orderId 订单id
        //certificateUrl 证书文件路径
        let obj = {"orderId":2, "certificateUrl":"zf.png"};
        this.getClient().postJson("/certificate/info/add", JSON.stringify(obj), (data) => {
            console.info('certificateInfoAdd, ');
            //{"code":0,"msg":"操作成功","clsName":null,"data":null}
            //-1, "订单不存在"
            //-2, "已过售后期"
            //-4, "订单状态不支持退款"
            //-5, "已经退款"
            return true;
        }, (err) => {
            console.error('certificateInfoAdd, ' + err);
            return false;
        }, this.token);
    }
}
